import request from '@/utils/request'

// 更新采购单
export function PurchaseOrderUpdateAPI(data) {
  return request({
    url: `/suppliers/purchase-orders/${data.purchase_order_code}/`,
    method: 'Patch',
    data
  })
}

// 获取采购订单
export function PurchaseOrdersAPI(params) {
  return request({
    url: '/suppliers/purchase-orders/',
    method: 'get',
    params
  })
}

// 根据采购订单获取采购订单详情
export function PurchaseOrderDeleteAPI(purchase_order_code) {
  return request({
    url: `/suppliers/purchase-orders/${purchase_order_code}/`,
    method: 'delete'
  })
}

// 获取采购明细
export function PurchaseDetailSearchAPI(params) {
  return request({
    url: `/suppliers/purchase-orders-item/`,
    method: 'get',
    params
  })
}

export function PurchaseDetailUpdateAPI(data) {
  return request({
    url: `/suppliers/purchase-orders-item/${data.id}/`,
    method: 'patch',
    data
  })
}

export function PurchaseOrderCreateAPI(data) {
  return request({
    url: '/suppliers/purchase-orders/',
    method: 'post',
    data
  })
}

export function PurchaseOrderDetailCreateAPI(data) {
  return request({
    url: '/suppliers/purchase-orders-item/',
    method: 'post',
    data
  })
}

export function PurchaseOrderDetailReadAPI(id) {
  return request({
    url: `/suppliers/purchase-orders-item/${id}/`,
    method: 'get'
  })
}

// 入库

export function PurchaseOrderInStorageListAPI(params) {
  return request({
    url: '/suppliers/purchase-receipts/',
    method: 'get',
    params
  })
}

export function PurchaseOrderInStorageCreateAPI(data) {
  return request({
    url: '/suppliers/purchase-receipts/',
    method: 'post',
    data
  })
}

export function PurchaseOrderInStorageUpdateAPI(data) {
  return request({
    url: `/suppliers/purchase-receipts/${data.purchase_receipt_code}/`,
    method: 'patch',
    data
  })
}

export function PurchaseOrderInStorageDeleteAPI(purchase_receipt_code) {
  return request({
    url: `/suppliers/purchase-receipts/${purchase_receipt_code}/`,
    method: 'delete'
  })
}

export function PurchaseOrderInStorageItemCreateAPI(data) {
  return request({
    url: '/suppliers/purchase-receipts-item/',
    method: 'post',
    data
  })
}

export function PurchaseOrderInStorageItemListAPI(params) {
  return request({
    url: '/suppliers/purchase-receipts-item/',
    method: 'get',
    params
  })
}

export function PurchaseOrderInStorageItemUpdateAPI(data) {
  return request({
    url: `/suppliers/purchase-receipts-item/${data.id}/`,
    method: 'patch',
    data
  })
}

export function PurchaseOrderInStorageItemDeleteAPI(id) {
  return request({
    url: `/suppliers/purchase-receipts-item/${id}/`,
    method: 'delete'
  })
}

// 采购退货单

export function PurchaseOrderReturnListAPI(params) {
  return request({
    url: '/suppliers/purchase-returns/',
    method: 'get',
    params
  })
}

export function PurchaseOrderReturnCreateAPI(data) {
  return request({
    url: '/suppliers/purchase-returns/',
    method: 'post',
    data
  })
}

export function PurchaseOrderReturnUpdateAPI(data) {
  return request({
    url: `/suppliers/purchase-returns/${data.purchase_return_code}/`,
    method: 'patch',
    data
  })
}

export function PurchaseOrderReturnDeleteAPI(purchase_return_code) {
  return request({
    url: `/suppliers/purchase-returns/${purchase_return_code}/`,
    method: 'delete'
  })
}

export function PurchaseOrderReturnItemUpdateAPI(data) {
  return request({
    url: `/suppliers/purchase-returns-item/${data.id}/`,
    method: 'patch',
    data
  })
}

export function PurchaseOrderReturnItemCreateAPI(data) {
  return request({
    url: '/suppliers/purchase-returns-item/',
    method: 'post',
    data
  })
}

export function PurchaseOrderReturnItemListAPI(params) {
  return request({
    url: '/suppliers/purchase-returns-item/',
    method: 'get',
    params
  })
}
